package com.yuchen.ishop.dictionary;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import com.yuchen.core.jdbc.BaseDao;
import com.yuchen.ishop.entity.Dictionary;
import org.apache.log4j.Logger;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 *
 */

@Path("dictionaryService")
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
@Produces({ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
public class DictionaryServiceImpl implements DictionaryService{

    private final static Logger LOG = Logger.getLogger(DictionaryService.class);

    @Autowired
    private BaseDao dao;

    @GET
    @Path("find/{dicKey}")
    @Transactional(readOnly = true)
    public List<Dictionary> find(@PathParam("dicKey")String dicKey) {
        Condition cnd = Cnd.where("dicKey","=",dicKey).asc("sort");
        List<Dictionary> list = dao.query(Dictionary.class, cnd);
        return list;
    }
}
